package com.yinhai.dialog;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;

import com.yinhai.activity.DialFragment;
import com.yinhai.activity.LocalContactAddActivity;
import com.yinhai.activity.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by lishm on 2018/6/9.
 */

public class DialDialog extends Dialog {

    @BindView(R.id.dial_nav_call)
    LinearLayout dialNavCall;
    @BindView(R.id.dial_nav_msg)
    LinearLayout dialNavMsg;
    @BindView(R.id.dial_nav_detail)
    LinearLayout dialNavDetail;
    @BindView(R.id.dial_cancel)
    LinearLayout dialCancel;


    public String itemTelphone;

    public DialDialog(@NonNull Context context) {
        super(context, R.style.dialog_bottom);
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.dial_nav);
        ButterKnife.bind(this);
        setCancelable(true);//点击外部不可dismiss
        setCanceledOnTouchOutside(true);
        Window window = this.getWindow();
        window.setGravity(Gravity.BOTTOM);
        WindowManager.LayoutParams params = window.getAttributes();
        params.width = WindowManager.LayoutParams.MATCH_PARENT;
        params.height = WindowManager.LayoutParams.WRAP_CONTENT;
        window.setAttributes(params);
    }

    @OnClick({R.id.dial_nav_call, R.id.dial_nav_msg, R.id.dial_nav_detail, R.id.dial_cancel})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.dial_nav_call:
                DialFragment.dial(getContext(), itemTelphone);
                break;
            case R.id.dial_nav_msg:
                DialFragment.msg(getContext(), itemTelphone);
                break;
            case R.id.dial_nav_detail:

                Intent mainIntent = new Intent(getContext(), LocalContactAddActivity.class);
                mainIntent.putExtra("phone", itemTelphone);
                mainIntent.putExtra("pagetype", 1);
                getContext().startActivity(mainIntent);
                // detail(itemTelphone);

                break;
            case R.id.dial_cancel:
                break;
        }

        dismiss();
    }
}
